﻿using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WPF.Project.Demo.ViewModels.Dialogs
{
    public class LoginViewModel : BindableBase, IDialogAware
    {

        public LoginViewModel()
        {
            ExecuteCommand = new DelegateCommand<string>(Execute);
        }

        public DelegateCommand<string> ExecuteCommand { get; private set; }


        #region IDialogAeare

        public string Title => "陈小厨私房菜";

        public event Action<IDialogResult> RequestClose;


        public bool CanCloseDialog()
        {
            return true;
        }

        public void OnDialogClosed()
        {

        }

        public void OnDialogOpened(IDialogParameters parameters)
        {

        }

        #endregion


        private string userName;
        public string UserName
        {
            get { return userName; }
            set { userName = value; RaisePropertyChanged(); }
        }


        private string passWord;
        public string PassWord
        {
            get { return passWord; }
            set { passWord = value; RaisePropertyChanged(); }
        }




        private void Execute(string obj)
        {
            switch (obj)
            {
                case "Login":
                    Login();
                    break;
                default:
                    break;
            }
        }

        /// <summary>
        /// 登录方法
        /// </summary>
        private void Login()
        {

            RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
        }
    }
}
